﻿namespace Pyramid.Hardware.MicroArchitecture
{
    using System.Collections.Generic;

    public class SimpleControlUnit
    {
        private readonly Register microInstructionRegister;

        public SimpleControlUnit(int busSize, int capacity, ILine clock, ILine counterReset)
        {
            var microInstructionPointer = new AsynchronousCounter(busSize, clock, counterReset);

            this.ControlStore = new AddressableRom(microInstructionPointer.OutputBus, busSize, capacity);

            this.microInstructionRegister = new Register(this.ControlStore.OutputBus, clock, FixedInputLine.True);
        }

        public AddressableRom ControlStore
        {
            get;
            private set;
        }

        public IEnumerable<ILine> OutputBus
        {
            get
            {
                return this.microInstructionRegister.OutputBus;
            }
        }
    }
}
